<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="white">
    <link rel="stylesheet" href="../dist/main.css">
</head>
<body>
<script src="../dist/main.js"></script>
<div id="fogetPass">
    <div class="mainBox">

        <div class="mui-input-row">
            <input type="password" placeholder="请输入原始密码" class="mui-input-password" id="oldPassword">

        </div>
        <div class="mui-input-row">
            <input type="password" placeholder="请输入新密码" class="mui-input-password" id="newPassword">

        </div>
        <div class="mui-input-row">
            <input type="password" placeholder="再次输入新密码" class="mui-input-password" id="newPassword2">

        </div>


        <div class="btns">
            <button class="mui-btn mui-btn-warning" id="sureChange">确定修改</button>
            <button class="mui-btn mui-btn-warning mui-btn-outlined" id="cansel">取消</button>
        </div>

    </div>
</div>
<script>
    $("title").html(mt5Obj.title)
    var bol=true;
    var mail=window.location.search.split("?")[1];

    mui("body").on('tap','#sureChange',function(){
        var oldPassword=$("#oldPassword").val();
        var newPassword=$("#newPassword").val();
        var newPassword2=$("#newPassword2").val();


        if (oldPassword=="" || newPassword==""){

            mui.alert("密码不能为空！")

        }else if(newPassword != newPassword2){
            mui.alert("两次输入密码不相符，请重新输入！")

        }else if(newPassword.length<6){
            mui.alert("密码最少6位数！")

        }
        else{
            $.ajax({
                url: mt5Obj.allUrl+"mt/user/updatePassword",
                type:"post",
                data:{
                    newPassword:newPassword,
                    oldPassword:oldPassword,
                },
                success: function(data){
                    if(data.data){
                        mui.confirm("登录密码修改成功，去登陆。",function(e) {
                            if(e.index == "1") {
                                goUrl("login");
                            }
                        })

                    }else{
                        mui.alert("修改失败！")
                    }
                }
            });
        }



    })

    mui("body").on('tap','#bolEmail',function(){
        var mail=$("#mail").val();
        var code=$("#code").val();
        if (emailGe(mail,$("#mail"))){
            return false;
        }else if (code==""){

            addWarn( $("#code"),"请输入邮箱验证码！");
        }
        else{
            $.ajax({
                url: mt5Obj.allUrl+"users/mailValidationCode",
                type:"post",
                data:{
                    mail:mail,
                    mailValidationCode:code,
                },
                success: function(data){
                    if(data.data){
                        mui.confirm("身份验证成功，修改新的登录密码。",function(e) {
                            if(e.index == "1") {
                                mui.openWindow({
                                    id:'fogetPass',
                                    url:'fogetPass2.html'
                                });
                            }
                        })
                    }else{
                        mui.alert("您的验证码填写错误，请重新输入")
                    }
                }
            });

        }


        // mui.alert("您的验证码填写错误，请重新输入")


    })
    mui("body").on('tap','#cansel',function(){
        goUrl("mine","4")
    })
    removeWarn()
</script>

</body>
</html>


